<?php
//-------------------------------------------------------------------------------------------------------
    require_once($config['app_dir'] . '/classes/user.class.php');
    require_once($config['app_dir'] . '/classes/contacts.class.php');
    require_once($config['app_dir'] . '/classes/translation.class.php');
    require_once($config['app_dir'] . '/classes/news.class.php');
    require_once($config['app_dir'] . '/classes/PerformanceTable.class.php');
    require_once($config['app_dir'] . '/classes/map.class.php');
    require_once($config['app_dir'] . '/includes/auxiliary.class.php');
    require_once($config['app_dir'] . '/classes/archive.class.php');
    //---------------------------------------------------------------------------------------------------
    class objURLTranslator {
            protected $data = array();
            protected $p = false;
            protected $s = false;
            public $m = false;

        public function  __construct($aM) {
            if( is_string($aM) ) $this->m = strtolower($aM);
            $this->build();
        }//constructor

        public function getMainMenu() {
            $mresult = $this->get();
            return $mresult['p'];
        }//getMainMenu

        public function getSubMenu() {
            $mresult = $this->get();
            return $mresult['s'];
        }//getSubMenu

        public function get() {
            $result = array();
            if( !$this->isEmpty() && array_key_exists($this->m, $this->data) )  $result = $this->data[$this->m];
            if( !$result ) $result = $this->m;
            return $result;
        }//get

        public function isEmpty() {
            return !$this->m;
        }//isEmpty

        //-----------------------------------------------------------------------------------------------

        protected function build() {
            $this->data =array();
            $this->data['404'] = array('p'=>'404', 's'=>false);
            $this->data['about'] = array('p'=>'about', 's'=>'about');
            $this->data['company'] = array('p'=>'about', 's'=>'about');
            $this->data['news'] = array('p'=>'about', 's'=>'news');
            $this->data['trading-systems'] = array('p'=>'about', 's'=>'tech');
            $this->data['media'] = array('p'=>'about', 's'=>'media');
            $this->data['testimonials'] = array('p'=>'about', 's'=>'testimonials');
            $this->data['partners'] = array('p'=>'about', 's'=>'partners');
            $this->data['user-guide'] = array('p'=>'about', 's'=>'guide');

            $this->data['managed-currency-accounts'] = array('p'=>'map', 's'=>'managed');
            $this->data['managed-accounts-benefits'] = array('p'=>'map', 's'=>'mapbenefits');
            $this->data['managed-accounts-overview'] = array('p'=>'map', 's'=>'mapoverview');
            $this->data['managed-accounts-brokers'] = array('p'=>'map', 's'=>'mapbrokers');
            $this->data['managed-accounts-client'] = array('p'=>'map', 's'=>'mapclient');
            $this->data['managed-accounts-calculator'] = array('p'=>'map', 's'=>'mapcalc');
            $this->data['managed-accounts-signup'] = array('p'=>'map', 's'=>'mapsignup');
            $this->data['managed-accounts-faq'] = array('p'=>'map', 's'=>'mapfaq');

            $this->data['forex-signals'] = array('p'=>'signals', 's'=>'signals');
            $this->data['dashboard'] = array('p'=>'signals', 's'=>'dashboard');
            $this->data['track-record'] = array('p'=>'signals', 's'=>'track');
			$this->data['trader'] = array('p'=>'signals', 's'=>'trader');
            $this->data['performance-calculator'] = array('p'=>'signals','s'=>'calc');
            $this->data['performance-archive'] = array('p'=>'signals', 's'=>'archive');
            $this->data['faq'] = array('p'=>'signals', 's'=>'faq');

            $this->data['free-trial'] = array('p'=>'signals', 's'=>'trial');
            $this->data['subscribe'] = array('p'=>'signals', 's'=>'subscribe');
            $this->data['subscribe-expired'] = array('p'=>'signals', 's'=>'expired');
            $this->data['rates-signup'] = array('p'=>'signals', 's'=>'subscribe');
			$this->data['signals-features'] = array('p'=>'signals', 's'=>'features');
            $this->data['performance-guarantee'] = array('p'=>'signals', 's'=>'guarantee');
            $this->data['forex-affiliate-program'] = array('p'=>'signals', 's'=>'affiliate');
            $this->data['fxstreet-audit'] = array('p'=>'signals', 's'=>'fxstreet');
            $this->data['forex-alerts-coverage'] = array('p'=>'signals', 's'=>'coverage');


            $this->data['auto-trading'] = array('p'=>'autotrading', 's'=>'autotrading');
			$this->data['auto-trading-signup'] = array('p'=>'autotrading', 's'=>'easignup');
			$this->data['expert-advisor-install'] = array('p'=>'autotrading', 's'=>'eainstall');
            $this->data['forex-brokers'] = array('p'=>'autotrading', 's'=>'autobrokers');
            $this->data['auto-trading-faq'] = array('p'=>'autotrading', 's'=>'autofaq');
			$this->data['expert-advisor-troubleshooting'] = array('p'=>'autotrading', 's'=>'eatrouble');

            $this->data['institutional-services'] = array('p'=>'inst', 's'=>'inst');
            $this->data['programming-services'] = array('p'=>'inst', 's'=>'instprogram');

            $this->data['login'] = array('p'=>'signin', 's'=>false);

            $this->data['rates'] = array('p'=>'rates', 's'=>false);


            $this->data['resources'] = array('p'=>'res', 's'=>false);
            $this->data['forex-market-analysis'] = array('p'=>'res','s'=>'analysis');
            $this->data['forex-forum'] = array('p'=>'res','s'=>'forum');
            $this->data['economic-calendar'] = array('p'=>'res','s'=>'ecocal');
            $this->data['forex-charts'] = array('p'=>'res','s'=>'flash');
            $this->data['quotations'] = array('p'=>'res','s'=>'quote');
            $this->data['glossary'] = array('p'=>'res','s'=>'glossary');

            $this->data['whitelist'] = array('p'=>'faq', 's'=>'whitelist');

            $this->data['contact-us'] = array('p'=>'contacts', 's'=>false);

            $this->data['settings'] = array('p'=>'settings', 's'=>false);
            $this->data['settings-billing'] = array('p'=>'settings', 's'=>'billing');
            $this->data['settings-trades'] = array('p'=>'settings', 's'=>'trades');
            $this->data['settings-personal'] = array('p'=>'settings', 's'=>'personal');

            $this->data['end-user-agreement'] =  array('p'=>'eula', 's'=>false);
            $this->data['risk-disclaimer'] = array('p'=>'rd', 's'=>false);
            $this->data['terms-conditions'] = array('p'=>'terms', 's'=>false);
            $this->data['site-map'] = array('p'=>'sitemap', 's'=>false);
            $this->data['privacy-policy'] = array('p'=>'pp', 's'=>false);

            $this->data['remind-password'] = array('p'=>'remind', 's'=>false);
            $this->data['confirm'] =  array('p'=>'signals', 's'=>'confirm');
            $this->data['unsubscribe']   = array('p'=>'unsubscribe', 's'=>false);
        }//build
    }//class URLTranslator
    //---------------------------------------------------------------------------------------------------
    class objMenu {
            public $public_root = '';
            protected $_page_name = false;
            protected $_page_menu = false;
            protected $_page_menu_main = false;
            protected $_page_menu_sub = false;
            protected $_main_menu = false;
            protected $_sub_menu = false;
            public  $TranslationMessage = false;

            protected $_main_menu_captions =
                array (// 'main menu item'
                    array('name'=>'about','url'=>'about'),
                    array('name'=>'map','url'=>'managed-currency-accounts'),
                    array('name'=>'autotrading','url'=>'auto-trading'),
                    array('name'=>'signals','url'=>'forex-signals'),
                    array('name'=>'res','url'=>'resources'),
                    array('name'=>'inst','url'=>'institutional-services'),
                    //array('name'=>'rates','url'=>'rates'),
                    //array('name'=>'faq','url'=>'faq'),
                    array('name'=>'contacts','url'=>'contact-us')
                                    );

            protected $_page_submenu =  array(
                            'about' => array(
                                'about'=> array('about','Company',1, 'about'),
                                'tech'=> array('tech','Technology',1, 'trading-systems'),
                                //'guide'=> array('guide','guide',1, 'user-guide'),
                                'news'=> array('news','News',1, 'news'),
                                'media'=> array('media','Media',1, 'media'),
                                'testimonials'=> array('testimonials','Testimonials',1, 'testimonials'),
                                'partners'=> array('partners','partners',1, 'partners'),
                            ),

                            'map' => array (
                            	//'managed'=> array('managed','MAP',1, 'managed-currency-accounts',array('mapsignup','mapcalc','mapoverview')),
                                'managed'=> array('managed','MAP',1, 'managed-currency-accounts'),
                                //'mapoverview'=> array('mapoverview','MAP',1, 'managed-accounts-overview'),
                                'mapbrokers'=> array('mapbrokers','MAP',1, 'managed-accounts-brokers'),
                                'mapsignup' => array('mapsignup','MAP',1,'managed-accounts-signup'),
                                //'mapbenefits'=> array('mapbenefits','MAP',1, 'managed-accounts-benefits'),
                                'mapclient'=> array('mapclient','MAP',1, 'managed-accounts-client'),
                                //'mapfaq'=> array('mapfaq','MAP',1, 'managed-accounts-faq'),
                                'mapcalc'=> array('mapcalc','MAP',0, 'managed-accounts-calculator')
                            ),
                            'autotrading' => array (
                            	'autotrading'=> array('autotrading','MAP',1, 'auto-trading'),
								'easignup'=> array('easignup','MAP',1, 'auto-trading-signup'),
								'eainstall'=> array('eainstall','MAP',1, 'expert-advisor-install'),
                            	'autofaq'=> array('autofaq','MAP',1, 'auto-trading-faq'),
								'autobrokers'=> array('autobrokers','MAP',1, 'forex-brokers'),
								'eatrouble'=> array('eatrouble','MAP',1, 'expert-advisor-troubleshooting')
                            ),
                            'inst' => array (
                            	'inst'=> array('inst','MAP',1, 'institutional-services')
                            	//'instprogram'=> array('instprogram','MAP',1, 'programming-services'),
                            ),
                            'signals' => array(
                                'signals'=> array('signals','Forex Signals',1, 'forex-signals',array('dashboard')),
                                'trial'=> array('trial','14-Day Trial',1,'free-trial'),
                                'Track Record' => array('track','Track Record',1,'track-record'),
                                'Forex Calculator' => array('calc','Forex Calculator',1,'performance-calculator'),
                                'Forecasts Archive'=> array('archive','Forecasts Archive',1,'performance-archive'),
                                'subscribe' => array('subscribe','Rates & Sign Up',1,'subscribe'),
								'features' => array('features','Rates & Sign Up',1,'signals-features'),
                                //'signup' => array('signup','Rates & Sign Up',0,'rates-signup'),
                                //'status'=> array('status','14-Day Trial',0,'status'),
                                'guarantee'=> array('guarantee','Performance Guarantee',1, 'performance-guarantee'),
                                'faq'=> array('faq','FAQ',1,'faq'),
                                'coverage'=> array('coverage','MAP',0, 'forex-alerts-coverage'),
                                'inst'=> array('inst','Institutional',0, 'institutional'),
                                'autotrading'=> array('autotrading','MAP',0, 'automated-trading')
                                //                        //'currency'=> array('currency','Currency',0,'currency')
                            ),
                            'res' => array(
                                //'analysis'=> array('analysis','analysis',1, 'forex-market-analysis'),
                                //'forum'=> array('forum','Forum',1, 'forex-forum'),
                                'ecocal'=> array('ecocal','Economic Calendar',1, 'economic-calendar'),
                                'flash'=> array('flash','Flash Forex Charts',1, 'forex-charts'),
                                'quote'=> array('quote','quote',1, 'quotations'),
                                'glossary'=> array('glossary','glossary',1, 'glossary')
                                //                        //'currency'=> array('currency','Currency',0,'currency')
                            ),

                            'rates' => array (
                                'trial'=> array('trial','14-Day Trial',1,'free-trial'),
                                'subscribe' => array('subscribe','Rates & Sign Up',1,'subscribe'),
                                //'signup' => array('signup','Rates & Sign Up',0,'rates-signup'),
                                //'status'=> array('status','14-Day Trial',0,'status'),
                                'guarantee'=> array('guarantee','Performance Guarantee',1, 'performance-guarantee')
                                //'Affiliate Program'=> array('affiliate','Affiliate Program',1,'affiliate-program')
                                //'expired'=> array('expired','Expired Subscription',0,'status')
                                //'pricing'=> array('pricing','Pricing'),
                                //'tour'=> array('tour','Tour'),
                                //'compare'=> array('compare','Compare'),
                                //'plans'=> array('plans','Plans')
                            ),
                            'faq' => array (
                                'general' => array('general','General'),
                                'forecast'=> array('forecast','Forecasts'),
                                'subscription'=> array('subscription','Subscription')
                            ),
                            'settings' => array (
                                'Subscription'=> array('subscription','Subscription',1,'settings-subscription'),
                                'E-mail and SMS notifications'=> array('notification','E-mail and SMS notifications',1,'settings-notification'),
                                'Trade systems and currency pairs' => array('trades','Trade systems and currency pairs',1,'settings-trades'),
                                'Money Management' => array('mmanagement','Money Management',1,'money-management'),
                                'MT4' => array('eatrades','Trade systems and currency pairs',1,'settings-ea-trades'),
                                //'Regional settings'=> array('regional','Regional settings',1,'settings-regional'),
                                'Password management'=> array('password','Password management',1,'settings-password')
                            )
                        );

            //based on main menu

            protected $_left_menu_templates =
                array (//0 'page_name' => 'left menu template'
                    'home' => 'texts/_left_home.tpl',
                    'about'=>'menus/menu_about.tpl',
                    'guide'=>'menus/menu_about.tpl',
                    'autotrading'=>'menus/menu_auto.tpl',
                    'inst'=>'menus/menu_inst.tpl',
                    'signals'=>'menus/menu_services.tpl',
                    //'signals'=>'menus/menu_forecasts.tpl',
                    'map'=>'menus/menu_perf.tpl',
                    'rates'=>'menus/menu_rates.tpl',
                    'tech'=>'menus/menu_technology.tpl',
                    'testimonials'=>'menus/menu_testimonials.tpl',
                    'res'=>'menus/menu_resources.tpl',
                    'faq'=>'menus/menu_faq.tpl',
                    'whitelist'=>'empty.tpl',
                    'contacts'=>'_trial.tpl',
                    'subscribe'=>'empty.tpl',
                    '404'=>'empty.tpl',
                    'settings'=>'menus/menu_settings.tpl',
                    'signin'=>'empty.tpl'
                    //'settings'=>'menus/menu_settings.tpl'
                );
            protected $_is_left =
                array (//0 'page_name' => '0|1'
                    'home' => '1',
                    'about'=>'1',
                    'autotrading'=>'1',
                    'inst'=>'1',
                    'signals'=>'1',
                    'signin'=>'1',
                    'guide'=>'1',
                    'map'=>'1',
                    'rates'=>'1',
                    'tech'=>'1',
                    'testimonials'=>'1',
                    'res'=>'1',
                    'faq'=>'1',
                    'contacts'=>'1',
                    'settings'=>'1',
                    '404'=>'1',
                    'none'=>'1'
                );

            //based on page
            protected $_is_right =
                array (//0 'page_name' => '0|1'
                	'home' => '0'
                );

            protected $_right_source_templates =
                array (//0 'page_name' => 'right source template'
                    'sitemap' => 'empty.tpl',
                    'pp' => 'empty.tpl',
                    'home' => 'empty.tpl',
                    'signin'=>'empty.tpl',
                    'about'=>'empty.tpl',
                    'guide'=>'empty.tpl',
                    'guarantee'=>'empty.tpl',
                    'forecasts'=>'empty.tpl',
                    'map'=>'empty.tpl',
                    'rates'=>'empty.tpl',
                    'tech'=>'empty.tpl',
                    'testimonials'=>'empty.tpl',
                    'res'=>'empty.tpl',//!!!!!!!!
                    'faq'=>'empty.tpl',
                    'contacts'=>'empty.tpl',
                    'confirm'=>'empty.tpl',
                    'subscribe'=>'empty.tpl',
                    '404'=>'empty.tpl',
                    'settings'=>'empty.tpl'
                );


            protected $_main_menu_items =
                array (
                    'signin'=>'none',
                    'confirm'=>'forecasts',
                    'remind' => 'none',
                    'sitemap'=>'none',
                    'pp'=>'none',
                    'eula'=>'none',
                    'rd'=>'none',
                    'terms'=>'none',
                    'guide'=>'none',
                    'guarantee'=>'rates',
                    '404'=>'404',
                    'settings'=>'settings',
                    'home' => 'home', //0 'page_name' => 'main menu item'
                    'about'=>'about', //1
                    'map'=>'map', //2
                    'autotrading'=>'autotrading', //3
                    'signals'=>'signals', //3
                    'inst'=>'inst', //3
                    'rates'=>'rates', //4
                    'tech'=>'tech', //5
                    'testimonials'=>'testimonials',
                    'res'=>'res',
                    'faq'=>'faq', //6
                    'contacts'=>'contacts'//7
                );


        public function __construct($p, $m, $s=false) {

            if('' == $m) $m = 'home';
            $this->_page_menu_main = $m;
            $this->_page_menu_sub = $s;
            $this->_page_menu = $p;

            $this->_page_name = $m;
            $this->_main_menu = $this->_main_menu_items[$m];

            $this->_sub_menu = $s;
        } //constructor

        function getTitle()	{
            if ($this->_sub_menu) $title = $this->TranslationMessage->GetMessage('titles__' . $this->_sub_menu);
            else $title = $this->TranslationMessage->GetMessage('titles__' . $this->_page_name);
            return $title;
        }

        function getKeywords() {
            return $this->TranslationMessage->GetMessage('keywords__' . $this->_page_name);
        }

        function getDescription() {
            return $this->TranslationMessage->GetMessage('descritions__' . $this->_page_name);
        }

        function getHeader() {
            if( $this->_sub_menu ) $header = $this->TranslationMessage->GetMessage('headers__' . $this->_sub_menu);
                else $header = $this->TranslationMessage->GetMessage('headers__' . $this->_page_name);
            return $header;
        }

        function getMenuLeftHeader() {
            return $this->TranslationMessage->GetMessage('left_menu_header__' . $this->_main_menu);
        }

        function getIsLeft() {
            return $this->_is_left[$this->_main_menu];
        }

        function getContentLeft() {
            if( !$this->_left_menu_templates[$this->_main_menu] ) return false;
            global $Staff;
            $Template = new objTemplate();

            // if page has a submenu pass appropriate variable to template
            if (array_key_exists($this->_main_menu, $this->_page_submenu)) {
                $menuData = $this->_page_submenu[$this->_main_menu];

                foreach($menuData as $menuKey => $menuItem) {

                    $menuData[$menuKey][1] = $this->TranslationMessage->GetMessage('sub_menu__' . $menuItem[0]);

                } //foreach


                $Template->Assign('menuData', $menuData);
            }
            $Template->Assign_by_ref('Staff', $Staff);
            $Template->Assign('menu_main', $this->getMainMenu());
            $Template->Assign('menu_sub', $this->getSubMenu());
            $Template->Assign('menu_page', $this->getPageMenu());

            return $Template->Fetch($this->_left_menu_templates[$this->_main_menu]);
        }

        function getIsRight() {
            return (array_key_exists($this->_page_name, $this->_is_right)?$this->_is_right[$this->_page_name]:false);
        }

        function getContentRight() {
            $Template = new objTemplate();
            return $Template->Fetch($this->_right_source_templates[$this->_page_name]);
        }

        function getMenuTop() {
            global $Staff;
            $menu_items = '';
            $submenu_items = '';
            foreach($this->_main_menu_captions as $item) {

                $TemplateSub = new objTemplate();
                $Template = new objTemplate();
                $Template->Assign('item', $item['name']);
                $Template->Assign('caption', $this->TranslationMessage->GetMessage('captions__' . $item['name']));

                $Template->Assign('link', '/'. $this->TranslationMessage->GetLang() . '/' . $item['url']. '.html');
                if( $this->_main_menu==$item['name'] )
                    $activeClass = 'active';
                else
                    $activeClass = 'noactive';
                $Template->Assign('class', $activeClass);

                $menu_items .= $Template->Fetch('menus/menu_top_item.tpl');
                //------------------------------------------------------------
                $TemplateSub = new objTemplate();
                //$TemplateSub->Assign('item', $item['name']);
                $nam = $item['name'];
                $subItems = array();
                //foreach($this->_page_submenu[$nam] as $subitem) {
                //$subItems[] = $subitem;
                //}
                $TemplateSub->Assign_by_ref('Staff', $Staff);
                $TemplateSub->Assign('item', $item['name']);
                $TemplateSub->Assign('items',$this->_page_submenu[$nam]);
                $TemplateSub->Assign('caption', $this->TranslationMessage->GetMessage('captions__' . $item['name']));
                $TemplateSub->Assign('link', '/'. $this->TranslationMessage->GetLang() . '/' . $item['url']. '.html');
                $TemplateSub->Assign('class', $activeClass);

                $submenu_items .= $TemplateSub->Fetch('menus/menu_sub_item.tpl');

            }
            $Template = new objTemplate();
            $Template->Assign('menu_items', $menu_items);
            $Template->Assign('submenu_items', $submenu_items);
            return $Template->Fetch('menus/menu_top.tpl');
        }

        public function getMainMenu() {
            return $this->_page_menu_main;
        } //getMainMenu

        public function getSubMenu() {
            return $this->_page_menu_sub;
        } //getSubMenu

        public function getPageMenu() {
            return $this->_page_menu;
        } //getPageMenu

        public function getRand() {
        	//get random forecast sample for not logged in users from set directory
            return objAuxiliary::getRandomFromRange(1, 3);
        } //getPageMenu

        public function getContent() {
          global $Staff, $config;

            $content = '';
            $Template = new objTemplate();

            switch( $this->_page_name )
            {
                //----------------------------------------------------------------------
                case "tech":
                    $content .= $Template->Fetch('texts/_technology.tpl');
        break;
                //----------------------------------------------------------------------
        case "res":
                    switch( $this->_sub_menu )
                    {
                    	case "analysis":
                            $content .= $Template->Fetch('texts/_market_analysis.tpl');
                        break;
                        case "forum":
                            $content .= $Template->Fetch('texts/_intelliforum.tpl');
                        break;

                        case "ecocal":
                            $content .= $Template->Fetch('texts/_ecocalendar.tpl');
                        break;

                        case "quote":
                            $content .= $Template->Fetch('texts/_intelliquote.tpl');
                        break;

                        case "glossary":
                            $content .= $Template->Fetch('texts/_fglossary.tpl');
                        break;

                        case "flash":
                        $content .= $Template->Fetch('texts/flashchart_login.tpl');
                        /*
                        if ( $Staff->Login() && $Staff->AccessAllowed() ) {

                            //$SystemSelector = new objSystemSelector(false, true);
                            //$content .= $SystemSelector->Render();

                            //$Tracks = new objTracks();
                            //$Tracks->TranslationMessage = $this->TranslationMessage;
                            //$Tracks->enable_active = 1;
                            //$content .= $Tracks->Render($isLite = true);

                            $content .= $Template->Fetch('texts/flashchart.tpl');


                            $Contacts = new objContactsDlg();
                            $content .= $Contacts->FlashFeedback();
                            $content .= $Contacts->ErrorStr();
                        } else {
                            $content .= "<br />Please <a href='login.html'>Sign In</a> to view this page.";
                        }
                        */
                    	break;

                        case "currency":
                            $content .= $Template->Fetch('texts/_currency.tpl');
                        break;
                    }
                break;
                //----------------------------------------------------------------------

        	case "flash":

                        if ( $Staff->Login() && $Staff->AccessAllowed() ) {

                            //$SystemSelector = new objSystemSelector(false, true);
                            //$content .= $SystemSelector->Render();

                            //$Tracks = new objTracks();
                            //$Tracks->TranslationMessage = $this->TranslationMessage;
                            //$Tracks->enable_active = 1;
                            //$content .= $Tracks->Render($isLite = true);

                            $content .= $Template->Fetch('texts/flashchart.tpl');


                            $Contacts = new objContactsDlg();
                            $content .= $Contacts->FlashFeedback();
                            $content .= $Contacts->ErrorStr();
                        } else {
                            $content .= "<br />Please <a href='login.html'>Sign In</a> to view this page.";
                        }

                    break;
			case "flashdemo":
					$content .= $Template->Fetch('texts/flashchart_demo.tpl');
                    break;





	        case "calculator":
	            $calc = new objCalculator();
	                $content .= $calc->Render($Staff);
	        break;

                //----------------------------------------------------------------------
                case "about":
                    switch( $this->_sub_menu )
                    {
                        case "tech":
                            $content .= $Template->Fetch('texts/_technology.tpl');
                            //$DashboardForecastsShow = new objDashboardForecastsShow();
                            //$content .= $DashboardForecastsShow->Render();
                        break;
                        //--------------------------------------------------------------
                        case "news":
                            $News = new objNews();
                            $News->TranslationMessage = $this->TranslationMessage;
                            $newsArr = $News->getNewsArr();
                            $Template->Assign('news',$newsArr);
                            $content .= $Template->Fetch('texts/_about_news.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "testimonials":
                            $content .= $Template->Fetch('texts/_testimonials.tpl');
                        break;
                         //--------------------------------------------------------------
                        case "media":
                            $content .= $Template->Fetch('texts/_about_media.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "team":
                            $content .= $Template->Fetch('texts/_about_team.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "partners":
                            $content .= $Template->Fetch('texts/_about_partners.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "guide":
                            $content .= $Template->Fetch('texts/_about_guide.tpl');
                        break;
                        //--------------------------------------------------------------
                        case "about":
                        default:
                            $content .= $Template->Fetch('texts/_about_company.tpl');
                    }
                break;
            //----------------------------------------------------------------------
                case "rates":


                    switch( $this->_sub_menu ){
                        case "guarantee":
                            $content .= $Template->Fetch('texts/_perf_guarantee.tpl');
                        break;
                        case "signup":
                        case $this->_page_submenu['rates']['trial'][0]:
                            if ( !$Staff->Login()){
                                $UserSignUp = new objUserSignUp($Staff);
                                $UserSignUp->TranslationMessage = $this->TranslationMessage;
                                $UserSignUp->public_root = $config['host']['root'];
                                $content .= $UserSignUp->Render();
                                break;
                            }
                            // Page shows status of subscription, Trial, Paypal returned status etc., for logged in users
                        case "expired":
                        case "status":
                            $Template->Assign_by_ref('Staff', $Staff);
                            $Template->Assign_by_ref('Order', $Order);
                            $Template->Assign('pageName', $this->_page_name);
                            $content .= $Template->Fetch('_order_status.tpl');
                         break;
                            // Sign-In page
                        case "signin":
                            if ( !$Staff->Login()){
                                $Template->Assign_by_ref('Staff', $Staff);
                                $content .= $Template->Fetch('_form_auth.tpl');
                                break;
                            }
                            // Subscribe Page
                        case 'subscribe'://$this->_page_submenu['rates']['subscribe'][0]:
                            //default:
                            $Template->Assign_by_ref('Staff', $Staff);
                            $Template->Assign_by_ref('Order', $Order);

                            $Template->Assign('pageName', $this->_page_name);
                            $content .= $Template->Fetch('_order_service.tpl');
                        break;
                        case "subscrtest":
                            $Template->Assign_by_ref('Staff', $Staff);
                            $Template->Assign_by_ref('Order', $Order);
                            $Template->Assign('pageName', $this->_page_name);
                            $content .= $Template->Fetch('_order_service_test.tpl');
                        break;
                        case "affiliate":
                            $content .= $Template->Fetch('texts/_affiliate_program.tpl');
                        break;
                    }
                break;

           //----------------------------------------------------------------------
                case "signals":
                	$Order = new objPayment();
                    $Order->TranslationMessage = $this->TranslationMessage;


                        switch( $this->_sub_menu ) {
							case "confirm":
		                    //if user uses system selector just after confirmation we should redirect to
		                    // proper forecasts page and set selected system
		                    if(!$_POST){
		                        $UserConfirm = new objUserConfirm($Staff);
		                        $UserConfirm->TranslationMessage = $this->TranslationMessage;
		                        $content .= $UserConfirm->Render();
		                        break;
		                    }
		                    //else $SystemSelector = new objSystemSelector(/*false, false*/);

                            case "signals":
                            case "dashboard":
                                if ( !$Staff->Login() ) {
                                    $Template->Assign('fileNum', $this->getRand());
                                    $content .= $Template->Fetch('texts/_info_forecasts.tpl');
                                } else {
                                    //$SystemSelector = new objSystemSelector(/*false, false*/);
                                    //$content .= $SystemSelector->Render();
                                    $Template->Assign_by_ref('Staff', $Staff);
                                    $content .= $Template->Fetch('texts/_sec_forecasts.tpl');
                                }
                            break;
                            //--------------------------------------------------------------
                            case "track":
							// default system temporarily set to Intraday (4)

                            $Tracks = new objTracks();
                            $Tracks->TranslationMessage = $this->TranslationMessage;
                            if ( $Staff->Login() && $Staff->AccessAllowed() ) $Tracks->enable_active = 1;
                            $content .= $Tracks->Render();
	                        break;
	                        //--------------------------------------------------------------
	                        case "calc":
	                            $SystemSelector = new objSystemSelector(1, false);
	                            $content .= $SystemSelector->Render();

	                            $calc = new objCalculator();
	                            $calc->system = $SystemSelector->GetSystem(false);
	                            $content .= '' . $calc->Render($Staff);
	                            $content .= $Template->Fetch('texts/_perf_calc.tpl');
	                        break;
	                        //--------------------------------------------------------------
	                        case "archive":
	                //default:
	                			// old archive is back
	                			$SystemSelector = new objSystemSelector($config['system']['default'], false);
	                            $content .= $SystemSelector->Render();

	                             $PerformanceTable = new objPerformanceTable();
	                            $Template->Assign('perfArr', $PerformanceTable->Build());
	                            $Template->Assign('pairArr', $PerformanceTable->BuildPairs());
	                            $content .= $Template->Fetch('texts/_performance.tpl');

	                            //$content .= objArchiveDispatcher::GetInstance()->Render();
	                        break;
	                        //--------------------------------------------------------------
	                        case "guarantee":
                            $content .= $Template->Fetch('texts/_perf_guarantee.tpl');
	                        break;
	                        case "signup":
	                        case $this->_page_submenu['rates']['trial'][0]:
	                            if ( !$Staff->Login()){
	                                $UserSignUp = new objUserSignUp($Staff);
	                                $UserSignUp->TranslationMessage = $this->TranslationMessage;
	                                $UserSignUp->public_root = $config['host']['root'];
	                                $content .= $UserSignUp->Render();
	                                break;
	                            }
	                            // Page shows status of subscription, Trial, Paypal returned status etc., for logged in users
	                        case "expired":
	                        case "status":
	                            $Template->Assign_by_ref('Staff', $Staff);
	                            $Template->Assign_by_ref('Order', $Order);
	                            $Template->Assign('pageName', $this->_page_name);
	                            $content .= $Template->Fetch('_order_status.tpl');
	                         break;
	                            // Sign-In page
	                        case "signin":
	                            if ( !$Staff->Login()){
	                                $Template->Assign_by_ref('Staff', $Staff);
	                                $content .= $Template->Fetch('_form_auth.tpl');
	                                break;
	                            }
	                            // Subscribe Page
	                        case 'subscribe'://$this->_page_submenu['rates']['subscribe'][0]:
	                            //default:
	                            $Template->Assign_by_ref('Staff', $Staff);
	                            $Template->Assign_by_ref('Order', $Order);

	                            $Template->Assign('pageName', $this->_page_name);
	                            $content .= $Template->Fetch('_order_service.tpl');
	                        break;
							case 'features':
	                            $content .= $Template->Fetch('texts/_signals_features.tpl');
	                        break;
	                        case "subscrtest":
	                            $Template->Assign_by_ref('Staff', $Staff);
	                            $Template->Assign_by_ref('Order', $Order);
	                            $Template->Assign('pageName', $this->_page_name);
	                            $content .= $Template->Fetch('_order_service_test.tpl');
	                        break;
	                        case "affiliate":
	                            $content .= $Template->Fetch('texts/_affiliate_program.tpl');
	                        break;
	                         case "fxstreet":
	                            $content .= $Template->Fetch('texts/_fxstreet_audit.tpl');
	                        break;
	                        case "coverage":
	                            $content .= $Template->Fetch('texts/_alerts_coverage.tpl');
	                        break;
	                        //--------------------------------------------------------------

                            case "whitelist":
                          		$content .= $Template->Fetch('texts/_faq_whitelist.tpl');
		                     break;
		                     case "faq":
		                     	$content .= $Template->Fetch('texts/_faq.tpl');
		                     break;

                    	}
                break;
                //----------------------------------------------------------------------
                 case "map":


                        switch( $this->_sub_menu ) {

                            case "managed":
                            		$Template->Assign('amountMinimal', $config['map']['minimal']);
                            		$Template->Assign('amountRecommend', $config['map']['recommend']);
	                                $content .= $Template->Fetch('texts/_service_map.tpl');

                            break;
                            case "mapbenefits":
                                $content .= $Template->Fetch('texts/_service_map_benefits.tpl');
                            break;
                            case "mapoverview":

                            	//error_reporting(E_ALL);

                                $MAPSelector = new objMAPSelector(false, false);
                                $content .= $MAPSelector->Render('snippet/form_mapselect.tpl');

                                $MAPPerformance = new objMAPPerformance();
                                $MAPPerformance->MAPID = $MAPSelector->GetMAPID();

								$Template->Assign('system', $MAPPerformance->MAPID);
								$Template->Assign('perfData', $MAPPerformance->GetPerformanceData());
								$Template->Assign('perfAvgData', $MAPPerformance->GetAvgPerformanceData());
                                $content .= $Template->Fetch('texts/_service_map_overview.tpl');
                            break;
                            case "mapcalc":

                            	//error_reporting(E_ALL);

                                $MAPSelector = new objMAPSelector(false, false);
                                $content .= $MAPSelector->Render('snippet/form_mapselect.tpl');

                                $mapcalc = new objCalculator();
                                //$mapcalc->system = 5;
                                $mapcalc->isMAP = true;
                                $content .= '' . $mapcalc->Render($Staff, true); // true flag means MAP calculator template
                                $Template->Assign('isMAP', true);
                                $content .= $Template->Fetch('texts/_perf_calc.tpl');
                            break;
                            case "mapbrokers":
                                $content .= $Template->Fetch('texts/_service_map_brokers.tpl');
                            break;
                            case "mapsignup":
                                $content .= $Template->Fetch('texts/_service_map_signup.tpl');
                            break;
                            case "mapclient":
                                $content .= $Template->Fetch('texts/_service_map_client.tpl');
                            break;
                            case "mapfaq":
                                $content .= $Template->Fetch('texts/_service_map_faq.tpl');
                            break;

                    	}
                break;
                //----------------------------------------------------------------------
                case "autotrading":
                	switch( $this->_sub_menu )
                    {
                    	case "autotrading":
                            $content .= $Template->Fetch('texts/_service_ea.tpl');
                        break;
						case "easignup":
                            $content .= $Template->Fetch('texts/_service_ea_signup.tpl');
                        break;
						case "eainstall":
                            $content .= $Template->Fetch('texts/_service_ea_install.tpl');
                        break;
                        case "autobrokers":
                            $content .= $Template->Fetch('texts/_service_ea_brokers.tpl');
                        break;
                        case "autofaq":
                            $content .= $Template->Fetch('texts/_service_ea_faq.tpl');
                        break;
						case "eatrouble":
                            $content .= $Template->Fetch('texts/_service_ea_trouble.tpl');
                        break;
                     }

                break;
                //----------------------------------------------------------------------
                case "inst":
                	switch( $this->_sub_menu )
                    {
                        case "inst":
                            $content .= $Template->Fetch('texts/_service_inst.tpl');
                        break;
                        case "instprogram":
                            $content .= $Template->Fetch('texts/_service_inst_programming.tpl');
                        break;
                     }
                break;

                //----------------------------------------------------------------------
                case "settings":
                    if ( !$Staff->Login() ) {
                    	$content .= $Template->Fetch('_form_auth.tpl');
                        break;
                    } else {
                    	$TranslationConf = objTranslationConf::GetInstance();
                    	$TranslationConf->RenderFile('brokers');

                        $UserProfile = new objUserProfile();
                        $UserProfile->TranslationMessage = $this->TranslationMessage;
                        $UserProfile->Staff = $Staff;
                        $UserProfile->id = $Staff->UserID();
                        $UserProfile->sub_menu = $this->_sub_menu;
                        $content .= $UserProfile->Render();
                    }
                break;
                //----------------------------------------------------------------------
                case "unsubscribe":
                    $UserUnsubscribe = new objUserUnsubscribe();
                    $content .= $UserUnsubscribe->Render();
                break;
                //----------------------------------------------------------------------
                case "remind":
                    $content .= $Template->Fetch('_form_remind_password.tpl');
                break;
                //----------------------------------------------------------------------
                case "contacts":
                    $Contacts = new objContactsDlg();
                    $content .= $Contacts->Render();
                    $content .= $Contacts->ErrorStr();
                break;
                //----------------------------------------------------------------------
        		case "timezone":
                    $content .= $Template->Fetch('texts/_time.tpl');
        		break;
       			 case "eula":
                    $content .= $Template->Fetch('texts/EndUserAgreement.tpl');
                break;
                case "rd":
                    $content .= $Template->Fetch('texts/RiskDisclaimer.tpl');
        		break;
                case "terms":
                    $content .= $Template->Fetch('texts/_terms.tpl');
        		break;
                //----------------------------------------------------------------------
                case "sitemap":
                    $content .= $Template->Fetch('menus/_site_map.tpl');
                break;
                case "pp":
                    $content .= $Template->Fetch('texts/_privacy_policy.tpl');
                break;
                case "signin":
                    if ( !$Staff->Login()){
                        $Template->Assign_by_ref('Staff', $Staff);
                        $content .= $Template->Fetch('_form_auth.tpl');
                        break;
                    } else {
                        $content .= $Template->Fetch('texts/_to_dashboard.tpl');
                    }
                break;
                case "404":
                    $content .= $Template->Fetch('texts/_error404.tpl');
                break;

                default:
                    //header('Location: /404.html');
                    $content .= $Template->Fetch('users/_js_redirect.tpl');
                break;
                //----------------------------------------------------------------------
            }
            return $content;
        } //run

        public function renderMainMenu() {
            $Template = new objTemplate();
            return $Template->fetch('menus/_main_menu.tpl');
        }//getMainMenu



        //////////////////////////////////////////////////////////////////////////

    } //class Menu
//-------------------------------------------------------------------------------------------------------
?>
